//
//  MYGNewsContentCollectionViewCell.swift
//  MYDoctor
//
//  Created by Mo on 2024/3/6.
//

import UIKit

class MYGNewsContentCollectionViewCell: UICollectionViewCell {
    var contentImageV:UIImageView!
    var titleLab:UILabel!
    var newsTitleLabel:UILabel!
    var newsContentLabel:UILabel!
    var modelDa:MYGNewsModel = MYGNewsModel(){
        didSet{
            contentImageV.sd_setImage(with: URL(string: modelDa.img))
            //titleLab.text = modelDa.data_type
            newsTitleLabel.text = modelDa.title
            newsContentLabel.text = modelDa.desc
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = .white
        self.layer.masksToBounds = true
        self.layer.cornerRadius = SCALEWIDTH(10)
        
        contentImageV = UIImageView()
//        contentImageV.contentMode = .scaleAspectFill
        self.contentView.addSubview(contentImageV)
        contentImageV.snp.makeConstraints { make in
            make.left.top.right.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(168))
        }
        
//        let typeImageV = UIImageView()
//        typeImageV.image = UIImage(named: "MYG_home_newsTitle")
//        self.contentView.addSubview(typeImageV)
//        typeImageV.snp.makeConstraints { make in
//            make.top.equalToSuperview()
//            make.right.equalToSuperview().offset(SCALEWIDTH(-7.5))
//            make.width.equalTo(SCALEWIDTH(54))
//            make.height.equalTo(SCALEWIDTH(21))
//        }
//        
//        titleLab = UILabel()
//        titleLab.textColor = RGBA(r: 255, g: 255, b: 255, a: 1)
//        titleLab.font = UIFont.systemFont(ofSize: 11, weight: .regular)
//        titleLab.text = ""
//        titleLab.textAlignment = .center
//        self.contentView.addSubview(titleLab)
//        titleLab.snp.makeConstraints { make in
//            make.top.equalToSuperview()
//            make.right.equalToSuperview().offset(SCALEWIDTH(-7.5))
//            make.width.equalTo(SCALEWIDTH(54))
//            make.height.equalTo(SCALEWIDTH(21))
//        }
//        typeImageV.isHidden = true
//        titleLab.isHidden = true
        newsTitleLabel = UILabel()
        newsTitleLabel.textColor = RGBA(r: 0, g: 0, b: 0, a: 1)
        newsTitleLabel.font = UIFont.systemFont(ofSize: 16, weight: .medium)
        newsTitleLabel.text = ""
        newsTitleLabel.lineBreakMode = .byTruncatingTail
        self.contentView.addSubview(newsTitleLabel)
        newsTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(contentImageV.snp.bottom).offset(SCALEWIDTH(7.5))
            make.left.right.equalToSuperview().inset(SCALEWIDTH(10))
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        
        newsContentLabel = UILabel()
        newsContentLabel.textColor = RGBA(r: 160, g: 160, b: 160, a: 1)
        newsContentLabel.font = UIFont.systemFont(ofSize: 13, weight: .regular)
        newsContentLabel.text = ""
        newsContentLabel.numberOfLines = 2
        self.contentView.addSubview(newsContentLabel)
        newsContentLabel.snp.makeConstraints { make in
            make.top.equalTo(newsTitleLabel.snp.bottom).offset(SCALEWIDTH(7.5))
            make.left.equalToSuperview().offset(SCALEWIDTH(10))
            make.right.equalToSuperview().offset(SCALEWIDTH(-10))
            make.bottom.equalToSuperview().offset(-SCALEWIDTH(15.5))
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
